package ca.uwindsor.cs.deepweb.utility;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class TxtDocumentHandler {
	
	protected String encoding;

	protected String title;

	protected String text;
	
	public TxtDocumentHandler(String encoding){
		this.encoding = encoding;
	}

	public void processContent(InputStream is) throws Exception {
		InputStreamReader f = new InputStreamReader(is,encoding);
		BufferedReader b = new BufferedReader(f);
		title = b.readLine();
		StringBuilder sb = new StringBuilder();
		String string_line = b.readLine();
		while (string_line != null) {
			sb.append(string_line);
			string_line = b.readLine();
		}
		text  = sb.toString();
	}
	
	public String getTitle() {
		return title;
	}

	public String getContent() {
		return text;
	}
}
